
//小红的子串  滑动窗口+前缀和
string str = "";
int left = 0, right = 0;
int find(int num)
{
    int res = 0;
    int l = 0, r = 0;
    unordered_map<char, int> hashtable;
    while (r < str.size())
    {
        hashtable[str[r]]++;
        while (hashtable.size() > num) {
            hashtable[str[l]]--;
            if (hashtable[str[l]] == 0) {
                hashtable.erase(str[l]);
            }
            ++l;
        }
        res += r - l + 1;
    }
}

int main()
{
    cin >> str >> left >> right;
    cout << find(right) - find(left - 1);
    
    return 0;
}